<?php

namespace App\Observers;

use App\Models\Apiuser;
class ApiuserObserver {
    //添加之前
    public function creating(Apiuser $apiuser){
        $apiuser->password = bcrypt(request()->get('password'));
    }
    //修改之前
    public function updating(Apiuser $apiuser){
        if (!empty($apiuser->password)){
            $apiuser->password = bcrypt(request()->get('password'));
        }
    }
}